package com.cy.springcloudalibaba.controllers;

import com.cy.springcloudalibaba.properties.UserProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 读取配置
 * @ClassName: ConfigController
 * @Author: chenyu
 * @Date: 2025/1/10 17:32
 */
@RestController
public class ConfigController {

    @Value("${user.name}")
    private String userName;

    @Value("${user.age}")
    private String userAge;

    @Autowired
    private UserProperty userProperty;

    @RequestMapping("/config")
    public String config() {
        return "userName: " + userName + "; userAge: " + userAge;
    }

    @RequestMapping("/config2")
    public String config2() {
        return "userName: " + userProperty.getName() + "; userAge: " + userProperty.getAge();
    }
}
